A series of triazole antifungal agents with piperidine side chains was designed and synthesized. The results of antifungal tests against eight human pathogenic fungi in vitro showed that all the compounds exhibited moderate-to-excellent activities. Molecular docking between 8d and the active site of Candida albicans CYP51 was provided based on the computational docking results. The triazole interacts with the iron of the heme group. The difluorophenyl group is located in the S3 subsite and its fluorine atom (2-F) can form H-bonds with Gly307. The side chain is oriented into the S4 subsite and formed hydrophobic and van der Waals interactions with the amino residues. Moreover, the phenyl group in the side chain interacts with the phenol group of Phe380 through the formation of π–π face-to-edge interactions.